import { GetMapping, RestController, RequsetParam, PathVariable } from "../decorator";
import { Autowired, Component } from "../ioc";
import TestService from "../service/TestService";

@RestController("/hello1")
@Component()
class Hello2Controller {
  @Autowired()
  private testService: TestService;

  constructor(testService: TestService) {
    console.log("Hello2Controller constructor");
    this.testService = testService;
  }
  @GetMapping("/hello2")
  hello2(@RequsetParam("userId") id?: string) {
    console.log("hello2");
    console.log(
      JSON.stringify(this.testService.getUser(id ? id : "1"))
    );
  }

  @GetMapping("/hello3/:userId")
  hello3(@PathVariable("userId") id?: string) {
    console.log("hello3");
    console.log(
      JSON.stringify(this.testService.getUser(id ? id : "1"))
    );
  }
}

// export default new Hello2Controller();
export default Hello2Controller;
